#!/bin/sh
#
# This script fake scrapes the internode
# unmetered radio site, downloads all pls files
# and renames to the station name.
#
cd /usr/media-library/audio/radio
rm index.html index.wget *.pls *.m3u
wget http://www.internode.on.net/residential/entertainment/broadband_radio/
grep -o 'http://[a-z./0-9]*pls' index.html > index.wget
wget -i index.wget


for PLAYLIST in *.pls
do
	# Ready titles for renaming files
	TITLE=`grep "Title1*" "${PLAYLIST}" | sed s/Title1\=//`
	TITLE=`echo ${TITLE} | sed s/\\:/\ -/`

	# Generate Bookmarks list for Streamer on iPhone
	URL=`grep "File1*" "${PLAYLIST}" | sed s/File1\=//`
	echo "# 1 ${TITLE}" >> playlist1.m3u
	echo "${URL}" >> playlist1.m3u

        echo ${TITLE}
        mv "${PLAYLIST}" "${TITLE}.pls"


done

# Copy to Wayne's iPhone
echo "Wayne's iPhone"
APPINST="790249FF-25CE-4F6B-A602-9B59DF3A1D23"
IPADD="192.168.0.98"
scp playlist1.m3u  mobile@${IPADD}:/private/var/mobile/Applications/${APPINST}/Documents

# Copy to Tracey's iPhone   
echo "Tracey's iPhone"
APPINST="0CDCE1B4-8C85-45A9-BED1-F9B6171DA2B8"
IPADD="192.168.0.97"
scp playlist1.m3u  mobile@${IPADD}:/private/var/mobile/Applications/${APPINST}/Documents

